/**
 * Copyright (C) 2012 Oleg Anastassov <o.anastasov@gmail.com>
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package kz.kstu.ent.business.entity.security;

import kz.kstu.ent.business.entity.Identifiable;
import kz.kstu.ent.business.entity.QueryNames;

import javax.persistence.*;

/**
 * @author Oleg Anastassov
 *         created: 27.09.11 19:48
 */
@Entity
@Table(name = "ACCOUNT")
@NamedQueries({
        @NamedQuery(name = QueryNames.FIND_ACCOUNT_BY_LOGIN, query =
                "SELECT A " +
                        "FROM Account A " +
                        "WHERE A.login = :login"
        ),
        @NamedQuery(name = QueryNames.FIND_ALL_ACCOUNTS, query =
                "SELECT A " +
                        "FROM Account A"
        )
})
public class Account implements Identifiable {

    private Long id;
    private String login;
    private String password;
    private boolean isBlocked;
    private boolean isAdmin;

    /**
     * {@inheritDoc}
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    @Override
    public Long getId() {
        return id;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "LOGIN", unique = true, nullable = false)
    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    @Column(name = "PASSWORD", nullable = false)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "IS_BLOCKED")
    public boolean isBlocked() {
        return isBlocked;
    }

    public void setBlocked(boolean blocked) {
        isBlocked = blocked;
    }

    @Column(name = "IS_ADMIN")
    public boolean isAdmin() {
        return isAdmin;
    }

    public void setAdmin(boolean admin) {
        isAdmin = admin;
    }
}
